package com.example.elearning.admin;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.widget.ListView;

import com.example.elearning.AdapterCourseListAdapter;
import com.example.elearning.ModelCourse;
import com.example.elearning.R;

import java.util.ArrayList;

public class AdminDashboard_Failed extends AppCompatActivity {
    private ArrayList<ModelCourse> videoArrayList;
    private AdapterCourseListAdapter adapterCourseListAdapter;
    private RecyclerView videosRv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_admin_dashboard);

//        videosRv = findViewById(R.id.courseRv);

        loadCourseList();
    }
    //加载课程
//    private void loadCourseList() {
//        videoArrayList = new ArrayList<ModelCourse>();
//        AdminHelper adminHelper = new AdminHelper(this);
//        SQLiteDatabase db = adminHelper.getWritableDatabase();
//        String query = "select * from " + AdminHelper.TABLE_COURSE;
//        Cursor cursor = db.rawQuery(query,null);
//        if (cursor.moveToFirst()) {
//            do {
///*
//            String title = cursor.getString(cursor.getColumnIndex(DatabaseHelper.COLUMN_TITLE));
//            这个语法不知道为啥错误。
// */
//                int a =cursor.getColumnIndex(AdminHelper.COURSE_CATEGORY);
//                String category = cursor.getString(a);
//                a =cursor.getColumnIndex(AdminHelper.COURSE_TITLE);
//                String title = cursor.getString(a);
//                a =cursor.getColumnIndex(AdminHelper.COURSE_TOTALLESSONS);
//                String totalLessons = cursor.getString(a);
//                a =cursor.getColumnIndex(AdminHelper.COURSE_TUTOR);
//                String tutor = cursor.getString(a);
//                a =cursor.getColumnIndex(AdminHelper.COURSE_TIMESTAMP);
//                String timestamp = cursor.getString(a);
//
////
////                ModelVideo modelVideo = new ModelVideo();
////
////                modelVideo.setTitle(title);
//
//
////                videoArrayList.add(modelVideo);
//
//                ModelCourse modelCourse = new ModelCourse();
//                modelCourse.setCategory(category);
//                modelCourse.setTitle(title);
//                modelCourse.setTotalLessons(totalLessons);
//                modelCourse.setTutor(tutor);
//                modelCourse.setTimestamp(timestamp);
//
//                videoArrayList.add(modelCourse);
//                videosRv.setAdapter(adapterVideo);
//            } while (cursor.moveToNext());
//        }
//
//    }

    private void loadCourseList(){
            videosRv.setAdapter(adapterCourseListAdapter);
            videosRv.setLayoutManager(new LinearLayoutManager(this));
    }
}